using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Reflection;

namespace Pay.Data {
	public class PayContext : DbContext {
#if DEBUG
		public PayContext() : base("Name=test_PayContext") { }
#else
		public PayContext() : base("Name=PayContext") { }
#endif
		public PayContext(DbCompiledModel model)
			: base("Name=PayContext", model) { }

		public PayContext(string nameOrConnectionString)
			: base(nameOrConnectionString) { }

		public PayContext(string nameOrConnectionString, DbCompiledModel model)
			: base(nameOrConnectionString, model) { }

		public PayContext(System.Data.Common.DbConnection existingConnection, bool contextOwnsConnection)
			: base(existingConnection, contextOwnsConnection) { }

		public PayContext(System.Data.Common.DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection)
			: base(existingConnection, model, contextOwnsConnection) { }

		public DbSet<BankNumber> BankNumbers { get; set; }
		public DbSet<Bill> Bills { get; set; }
		public DbSet<BillDetail> BillDetails { get; set; }
		public DbSet<Bulletin> Bulletins { get; set; }
		public DbSet<Order> Orders { get; set; }
        public DbSet<OrderItem> OrderItems { get; set; }
		public DbSet<Charge> Charges { get; set; }
		public DbSet<Feature> Features { get; set; }
		public DbSet<Manage> Manages { get; set; }
		public DbSet<Role> Roles { get; set; }
		public DbSet<RoleFeature> RoleFeatures { get; set; }
		public DbSet<Merchant> Merchants { get; set; }
        public DbSet<MemberPath> MemberPaths { get; set; }
        public DbSet<MessagePush> MessagePushs { get; set; }
		public DbSet<PayInfo> PayInfos { get; set; }
		public DbSet<RefundOrder> RefundOrders { get; set; }
		public DbSet<Refund> Refunds { get; set; }
		public DbSet<Region> Regions { get; set; }
		public DbSet<Setting> Settings { get; set; }
		public DbSet<Transfer> Transfers { get; set; }
		public DbSet<TransferBatch> TransferBatchs { get; set; }
		public DbSet<PlatBill> PlatBills { get; set; }
		public DbSet<PlatBillDetail> PlatBillDetails { get; set; }
		public DbSet<Payment> Payments { get; set; }
		public DbSet<Product> Products { get; set; }
		public DbSet<ProfitDay> ProfitDays { get; set; }
		public DbSet<Category> Categories { get; set; }
		public DbSet<SkuInfo> SkuInfos { get; set; }
		public DbSet<SkuValue> SkuValues { get; set; }
		public DbSet<ProductSku> ProductSkus { get; set; }
		public DbSet<AuthInfo> AuthInfos { get; set; }
		public DbSet<PayHtml> PayHtmls { get; set; }
		public DbSet<PayNotify> PayNotifys { get; set; }
		public DbSet<MerchantRegister> MerchantRegisters { get; set; }
		public DbSet<MerchantPayment> MerchantPayments { get; set; }
		public DbSet<MerchantDeclaration> MerchantDeclarations { get; set; }
		public DbSet<GoodDeclaration> GoodDeclarations { get; set; }
        public DbSet<MerchantCertification> MerchantCertifications { get; set; }
        public DbSet<Topic> Topics { get; set; }
		public DbSet<TopicProduct> TopicProducts { get; set; }
		public DbSet<TopicGroup> TopicGroups { get; set; }
        public DbSet<ShippingPosition> ShippingPosition { get; set; }
        public DbSet<Grade> Grades { get; set; }
        public DbSet<Article> Articles { get; set; }
        public DbSet<ReplyArticle> ReplyArticles { get; set; }

        public DbSet<CardApply> CardApplys { get; set; }
        public DbSet<Logistics> Logistics { get; set; }
        public DbSet<LogisticsDetails> LogisticsDetails { get; set; }
        public DbSet<LogisticsNO> LogisticsNO { get; set; }
        public DbSet<DistributionProduct> DistributionProducts { get; set; }
        public DbSet<Entrepot> Entrepots { get; set; }
        public DbSet<Cart> Carts { get; set; }
        public DbSet<ShippingAddress> ShippingAddresses { get; set; }
        public DbSet<PostFee> PostFees { get; set; }

        public DbSet<LogisticsList> logisticsLists { get; set; }

        public DbSet<TokenInfo> TokenInfo { get; set; }

        public DbSet<Notice> Notice { get; set; }
        public DbSet<NoticeUserReadHis> NoticeUserReadHis { get; set; }

        public DbSet<MerchIntroduce> MerchIntroduce { get; set; }

        public DbSet<SoupTask> SoupTask { get; set; }

        public DbSet<UserSoupValueHis> UserSoupValueHis { get; set; }

        public DbSet<UserSoupValueSnap> UserSoupValueSnap { get; set; }

        public DbSet<Collect> Collects { get; set; }

        public DbSet<RedRecord> RedRecord { get; set; }
        public DbSet<RedRecordDetail> RedRecordDetail { get; set; }
        public DbSet<RedProductRecordDetail> RedProductRecordDetail { get; set; }
        public DbSet<Advertisement> Advertisement { get; set; }
        public DbSet<UserInvitationHis> UserInvitationHis { get; set; }
        public DbSet<WXVerificationCode> WXVerificationCode { get; set; }
        public DbSet<ConsumeItem> ConsumeItem { get; set; }
        public DbSet<UserComsumeHis> UserComsumeHis { get; set; }

        public DbSet<UserFeedBack> userFeedBacks { get; set; }
        public DbSet<ConsumeProduct> ConsumeProduct { get; set; }

        public DbSet<Activity> Activity { get; set; }
        public DbSet<PlayingTeam> PlayingTeam { get; set; }
        public DbSet<Playing> Playing { get; set; }
        public DbSet<UserGuessPlayingHis> UserGuessPlayingHis { get; set; }
        public DbSet<SMSVerificationCode> SMSVerificationCode { get; set; }
        public DbSet<UserRedTransferHis> UserRedTransferHis { get; set; }
        public DbSet<UserRedTransferBenefit> UserRedTransferBenefit { get; set; }
        public DbSet<TokenShopSubject> TokenShopSubject { get; set; }
        public DbSet<TokenShopSubjectProduct> TokenShopSubjectProduct { get; set; }
        public DbSet<Course> Course { get; set; }
        public DbSet<MarketingTokenInfo> MarketingTokenInfo { get; set; }
        public DbSet<MerchantReceivables> MerchantReceivables { get; set; }
        public DbSet<QuotaRecord> QuotaRecord { get; set; }
        public DbSet<TokenGrade> TokenGrade { get; set; }
        public DbSet<TokenUpGrade> TokenUpGrade { get; set; }
        public DbSet<TokenBill> TokenBill { get; set; }
        public DbSet<TokenBillDetail> TokenBillDetail { get; set; }
        public DbSet<TokenStatistics> TokenStatistics { get; set; }
        public DbSet<IPFilterInfo> IPFilterInfo { get; set; }
        public DbSet<ShopInfo> ShopInfo { get; set; }
        public DbSet<TokenTransfer> TokenTransfer { get; set; }
        public DbSet<MerchantBankCard> MerchantBankCard { get; set; }
        public DbSet<InviteHorsePowerSetting> InviteHorsePowerSetting { get; set; }
        public DbSet<TokenTaskDayLogin> TokenTaskDayLogin { get; set; }
        public DbSet<TokenTaskUpgrade> TokenTaskUpgrade { get; set; }
        public DbSet<TokenTaskMayi> TokenTaskMayi { get; set; }
        public DbSet<TokenTaskCreditCard> TokenTaskCreditCard { get; set; }
        public DbSet<TokenTaskApplyLoan> TokenTaskApplyLoan { get; set; }
        public DbSet<TokenTaskWatchLive> TokenTaskWatchLive { get; set; }
        public DbSet<TokenTaskMallShopping> TokenTaskMallShopping { get; set; }
        public DbSet<ProductTokenMaker> ProductTokenMaker { get; set; }
        public DbSet<TokenTaskViewMall> TokenTaskViewMall { get; set; }
        public DbSet<TokenBazaarProduct> TokenBazaarProduct { get; set; }
        public DbSet<TokenBazaarOrder> TokenBazaarOrder { get; set; }
        public DbSet<TokenShipping> TokenShipping { get; set; }
        public DbSet<RedFrozenRecord> RedFrozenRecord { get; set; }
        public DbSet<OrderRefund> OrderRefund { get; set; }
        public DbSet<ProductActivity> ProductActivity { get; set; }
        public DbSet<ProductActivityTimeBuy> ProductActivityTimeBuy { get; set; }
        public DbSet<Profit> Profits { get; set; }
        public DbSet<MerchantFaces> MerchantFaces { get; set; }
        public DbSet<BankCode> BankCodes { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
			var typesToRegister = Assembly.GetExecutingAssembly().GetTypes()
				 .Where(type => !String.IsNullOrEmpty(type.Namespace))
				 .Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(EntityTypeConfiguration<>));
			foreach (var type in typesToRegister) {
				dynamic configurationInstance = Activator.CreateInstance(type);
				modelBuilder.Configurations.Add(configurationInstance);
			}

			base.OnModelCreating(modelBuilder);
		}
	}
}